<%--
  Created by IntelliJ IDEA.
  User: 世界上最帅的詹姆斯
  Date: 2021-02-07
  Time: 9:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath() + "/";
%>
<html>
<head>
    <title>Title</title>
</head>
<link href="<%=basePath%>join/css/style.css" rel="stylesheet" type="text/css">
<link href="<%=basePath%>join/css/nice-select.css" rel="stylesheet" type="text/css">
<link type="text/css" rel="stylesheet" href="<%=basePath%>page/layui/css/layui.css">
<body>

<div style="position: relative;margin: 50px"> <h4>我的订单</h4></div>
<div style="position: relative;left: 700px;top: -70px">
    <select>
        <option data-display="近六个月订单">近六个月订单</option>
        <option value="1">待入住</option>
        <option value="2">待付款</option>
        <option value="3" >已完成</option>
        <option value="4" >近六个月订单</option>
    </select>
</div>
<br>
<div>
    <ul>
        <c:forEach items="${ord}" var="a">
            <li >
                <div style="border: 1px solid lightgrey;border-bottom: none;background: #ececec;width: 850px;height: 40px;position: relative;left: 50px">
                    <span style="font-size: 12px;position:absolute;left:80px;top: 10px">订单号：<a style="color: #666666">${a.orderid}</a></span>
                    <span style="font-size: 12px;position:absolute;left: 300px;top: 10px">预定日期：${a.otime.split(" ")[0]}</span>
                </div>
                <div style="border: 1px solid lightgrey;border-top: none;background: white;width: 850px;position: relative;left: 50px;height: 180px">
                    <div style="display: inline-block">
                        <div style="padding: 30px 15px 30px 30px;display: inline-block"><a><img src="<%=basePath%>${a.rimg.split("\\\\")[2]}" width="160px" height="120px"></a></div>
                        <div style="display: inline-block;position: relative;top: 25px">
                            <h4 style="font-size: 14px;color: #333333;">湖南省长沙市岳麓区xxxxx</h4>
                            <p style="color: #999999;font-size: 12px ;position: relative;top: 10px">${a.rtname}</p>
                            <p style="color: #999999;font-size: 12px ;position: relative;top: 10px">入住日期：${a.otime.split(" ")[0]}</p>
                            <p style="color: #999999;font-size: 12px ;position: relative;top: 10px">离店日期：${a.outTime}</p>
                            <p style="color: #999999;font-size: 12px ;position: relative;top: 10px">共${a.onumber}晚</p>
                        </div>
                    </div>
                    <div style="position:relative;left:10px;top:10px;display: inline-block;width: 160px;height: 120px;line-height: 120px" align="center">
                        <div>
                            <p>总价</p>
                            <p style="font-size: 20px;color: red">￥<span>${a.rtprice*a.onumber}</span>
                            </p>
                        </div>
                    </div>
                    <div style="display: inline-block;width: 160px;height: 120px;line-height: 120px" align="center">
                        <div>
                            <p>${a.state}</p>
                        </div>
                    </div >
                    <div style="display: inline-block;width: 160px;height: 120px;line-height: 120px;position: relative;top: -160px;left: 680px" align="center">
                        <div >
                            <a class="layui-btn layui-btn-normal" href="<%=basePath%>BookList" target="_blank" style="color: aliceblue">再次预定</a>
                            <a class="layui-btn layui-btn-normal" style="position:relative;left: -5px;top: 30px;color: aliceblue" onclick="delOrder(${a.orderid})">删除订单</a>
                        </div>
                    </div>

                </div>
            </li>
            <br>
        </c:forEach>
    </ul>
</div>

</body>
<script src="<%=basePath%>page/layui/layui.js"></script>
<script src="<%=basePath%>join/js/jquery.js"></script>
<script src="<%=basePath%>join/js/jquery.nice-select.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>

    $(document).ready(function() {
        $('select').niceSelect();
    });
    layui.use('element','jquery', function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        var $=layui.jquery;

        //监听导航点击
        element.on('nav(demo)', function (elem) {
            //console.log(elem)
            layer.msg(elem.text());
        });


    });

    function delOrder(orderid) {
        //拿到需要删除的订单id
        $.ajax({
           url:'<%=basePath%>userDelOrder',
            dataType:'json',
            data:{orid:orderid},
            type: 'post',
            async: false,
            success : function(data) {
                if (data === false) {
                    layer.msg('删除失败！', {
                        icon : 5,
                        offset : "auto",
                        time : 2000
                    });//提示框
                } else if (data===true){
                    alert("chengg")
                    layer.msg('删除成功',{incon:6,time:2000,offset:'auto'});
                   window.location.reload();
                }

            }

        });
        return false;
    }
</script>
</html>
